
#ifndef H_RCGD_DEFINE_H
#define H_RCGD_DEFINE_H


#define PrintMessage(msg);   if(SYSTEM.IO.CTRL_PORT.MODE==UCOMMAND){sprintf((char*)MESG,msg);\
								TransmitMessage((BYTE*)MESG,PORT_CONTROL);}

#define MessageOut(msg);   if(SYSTEM.IO.CTRL_PORT.MODE==UDEBUG){TransmitMessage((unsigned char*)msg,PORT_CONTROL);}
//#define MessageOut(msg);   //kang printf(msg);

/* #define SendPrompt();		TransmitnMessage((unsigned char*)"\r\nIS-2000> ",11,PORT_CONTROL);*/
#define SendPrompt();		TransmitnMessage((unsigned char*)PROMPT,PROMPT_LENGTH,PORT_CONTROL);



#ifdef	_DEBUG_LOG
#define DEBUG_LOG(number);	LogIt(LOG_CATA1_NORM, LOG_CATA2_NOTHING, LOG_DEBUG,number);
#else
#define DEBUG_LOG(number);
#endif

/*=================================================================*/
/*                            define                               */
/*=================================================================*/
/*----------------------------------------------------*/
/*             for PTFS-CHB                           */
/*----------------------------------------------------*/
#define     ModuleA 0
#define     ModuleB 1

#define		ModeBTS	1
#define		ModeBSC	0


#define     YES    1
#define     NO     0
#define     OFF    0
#define     ON     1
#define     FAIL   0
#define     COM_FAIL	2
#define     OK     1
#define     ENABLE 1
#define     DISABLE 0


#define     ING   127
#define     UNDEFINED   126

#define     PAUSE   10

#define		POLL	5

#define     EB_ANT_FAIL 99
#define     EB_ANT_OK   100

#define     EVEN    0
#define     ODD     1

#define     PLUS    1
#define     MINUS  -1


#define     TIMEMODE_GPS     0
#define     TIMEMODE_UTC     1
#define     TIMEMODE_RTC     2

#define     TENMILLION  10000000
#define     BILLION     1000000000

#define     SUCCESS 0
#define     TOUP    1
#define     TODOWN  2



/* User Command */
#define 	UERROR      		-1
#define 	UTOD        		0
#define		UTOD_ASCII			10
#define 	UCOMMAND       		1
#define 	USTATUS_ASCII     	2
#define 	USTATUS_BINARY    	7
#define 	USTATUS_TEXT    	27
#define 	UDEBUG      		3
#define 	UDEBUG2      		12
#define 	UDEBUG3      		13
#define 	UDEBUG4      		14
#define 	UDEBUG5      		15
#define 	UDEBUG6      		16
#define 	UDEBUG7      		17
#define 	UDEBUGD      		18
#define 	UDEBUG9      		19
#define 	UDOWNLOAD			4

#define 	UDEBUG_DETAIL			100
#define 	UDEBUG_DETAIL2			101
#define 	UDEBUG_OFFSET			102
#define		UDEBUG_DBG				103

#define 	UDEBUG_TIME				104


#define		UHELP				9


#define 	UWAIT_TO_COMMAND 	11
#define		UWAIT_HELP			35
#define		UDISPLAY_HELP		29

#define		UDISPLAY_LOG		30
#define		UWAIT_LOG			31

#define		UDISPLAY_TLOG		33
#define		UWAIT_TLOG			34

#define		UWAIT_TO_PROMPT 	32

#define		ODT_COMMAND			41
#define		RB_COMMAND			42
#define		EB_COMMAND			43

#define		REV_COMMAND			44

#define		UWAIT_MEMORY_PRINT		51


/* SYSTEM.OPERATION.OPMODE */
#define     OPMODE_POWERUP            0
#define     OPMODE_WARMUP             1
#define     OPMODE_OPERATION          2


/* SYSTEM.OPERATION.LOCKMODE */
#define     LOCKED                  0
#define     HOLDOVER                1
#define     UNLOCKED                3
#define		RECOVERYfromUNLOCKED	4
#define		HOLDOVER_OVER10MIN		5


/* SYSTEM.OPERATION.CTRLMODE */
#define     CTRL_LOCKEDtoGPS        0
#define     CTRL_LOCKEDtoMASTER     1


/* SYSTEM.OPERATION.STATUS */
#define     STATUS_ACTIVE           1
#define     STATUS_STANDBY          2
#define     STATUS_BLOCK            3
#define		STATUS_PRE_STANDBY		4
#define		STATUS_ACTIVE_BLOCKED	5

#define		STATUS_UNKNOWN			6

#define 	NOT_EXIST				9


/* SYSTEM.EB.LOCKMODE */
#define     EB_LOCKED       	0
#define     EB_UNLOCKED     	1
#define		EB_3D_FIX			2
#define		EB_POSITION_HOLD	3


/* SYTEM.EB. ID */
#define		UT_ONCORE		0
#define		UT_PLUS_ONCORE	1
#define		SYNC_15			2


/* SYTEM.EB.SUBID */
#define		SYNC15_ORI		1
#define		SYNC15_N		2
#define		SYNC15_T		3


#undef NULL
#define NULL    '\0'


/* ANTENNA */
#define	ANTENNA_OK		1
#define	ANTENNA_OPENED	2
#define	ANTENNA_SHORTED	3




/*---------------------------------------------------------------------*/
/*                     DAC Serial Input                                */
/*---------------------------------------------------------------------*/

#ifdef PTFS_CS
#define TS_OCXO        0x0000
#define TS_EXT         0x0001
#endif

#ifdef PTFS_CH
#define TS_OCXO        	0
#define TS_EXT         	1
#define TS_CURRENT		2
#endif

#define NAVICOM_COMMAND	0
#define HP_COMMAND 		1
#define DATUM_COMMAND 	2
#define Odetic_COMMAND	3


#define upper(c)    ((c >= 'a') ? c-32 : c)
#define get_msec()	(TimeSliceCounter * 10)



#define NO_SHIFT	0
#define PLUS_SHIFT	1
#define MINUS_SHIFT 3
#define RESYNC_SHIFT 4

#define MAbs(x)	( (x>0) ? (x): -(x))
#define	max(a,b)	( (a>b)? (a): (b))
#define	min(a,b)	( (a<b)? (a): (b))

#define GPSTXBUFSIZE 400
#define GPSRXBUFSIZE 3840
#define GPS_RX_TIMEOUT 4

#define TRAIM_QUERY_NULL 0
#define TRAIM_QUERY_ING 1
#define TRAIM_QUERY_DONE 2

#define MAX_EB_RESET 3





#endif

